<template>
<div>
	<content_top title="团队损益表"></content_top>
	
	<div class="g_box">
		<div class="g_head">
			<h3>筛选查询</h3>
			<div class="g_box_right">
				<ButtonGroup class="g_act_box">
					<Button @click="export_data">导出表格</Button>&nbsp;&nbsp;&nbsp;&nbsp;
					<Button @click="qurey">查询结果</Button>
				</ButtonGroup>
				<div class="g_other">
					<a @click="clear_data">全部清除</a>
				</div>
			</div>
		</div>
		<div class="g_box_con" style="padding:20px;">
			<Form  :label-width="90" style="width: 100%" inline>
				<FormItem label="地区：">
					<region_list v-model="filter.region" field="name" style="width:150px;"></region_list>
				</FormItem>
				<FormItem label="部门：">
					<bumen_filter v-model="filter.bumen" field="name" style="width:150px;"></bumen_filter>
				</FormItem>
				<FormItem label="年份：">
					<DatePicker :value="filter.date" type="year" placeholder="选择年份" style="width: 150px" @on-change="month_change"></DatePicker>
				</FormItem>
				
				<FormItem label="兑换币别：">
					<currency_filter v-model="bz" field="name" @change="currency_change" :allow_data="['人民币','港币','新加坡币']"></currency_filter>
				</FormItem>
				<FormItem label="币别汇率：">
					<Input :value="exchange_rate" disabled style="width:150px;"></Input>
				</FormItem>
			</Form>
		</div>
	</div>

	<!-- 表格 -->
	<table_item :cinfo="info"></table_item>
	
</div>
</template>

<script>

import table_item from './table_item';
import region_list from '@/themes/components/region_list';
import bumen_filter from '@/themes/components/bumen_filter';
import currency_filter from '@/themes/components/currency_filter';



export default {
    name: 'income_list',
    data () {
		let self = this;
        return {
			filter:{
				region:'',
				company:'',
				date:new Date().Format('yyyy'),
				
			},
			info:[],
			bz:'人民币',
			exchange_rate:1.0
        };
	},
	components:{
		table_item,
		region_list,
		bumen_filter,
		currency_filter
	},
	created(){
		
		this.load_data();
	},
    computed: {
       
    },
	methods:{
		load_data(){
			var self = this;
			
			var postdata = {
				f:this.filter,
				bz:this.bz
			};
			
			Whttp.load('Report/Team/query',postdata,function(result){
				self.info = result;
			});
		},
		qurey(){
			this.load_data();
		},
		
		month_change(date){
			this.filter.date =  date;
		},
		currency_change(val){
			this.exchange_rate = val.exchange_rate;
		},
		export_data(){
			var self = this;
			
			var postdata = {
				f:this.filter,
				bz:this.bz
			};
			
			Whttp.load('Report/Team/export_data',postdata,function(result){
				window.open(result);
			});
		},
		clear_data(){
			this.filter = this._getData(this.default_filter);
			this.bz = '';
			this.exchange_rate = 1.0;
		}
	}
};
</script>
<style scoped>
.price{
	color: red;
    margin: 0 5px;
}
.kemu_list .ivu-col-span-4{
	font-size: 18px;
	margin-bottom:8px;
}
</style>